<template>
  <van-image fit="cover" :src="imgSrc" v-bind="$attrs">
    <template v-slot:error>
      <img :src="defaultImg" alt="" />
    </template>
  </van-image>
</template>

<script>
export default {
  props: {
    src: {
      default: '',
      type: String
    }
  },
  data() {
    return {
      defaultImg: require('assets/images/default.png')
    }
  },
  computed: {
    imgSrc() {
      return this.src ? this.src : this.defaultImg
    }
  }
}
</script>
<style lang="scss" scoped>
.van-image {
  overflow: hidden;
}
img {
  width: 100%;
  height: 100%;
}
</style>